/*
 * Home.java
 *
 * Created on January 29, 2007, 11:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package ge.info.pages;

import ge.info.domain.StringString;
import ge.ktapestry.pages.BasePageExt;
import org.apache.tapestry.IRequestCycle;


import java.util.*;

public abstract class CityDistances extends BasePageExt
{
    
    public static int SERVICE_ID = 31;

    public abstract String getCityOne();

    public abstract void setCityOne(String s);

    public abstract String getCityTwo();

    public abstract void setCityTwo(String s);

    public abstract List<TreeMap> getDistanceMessages();

    public abstract void setDistanceMessages(List<TreeMap> list);

    public abstract TreeMap getMessage();

    public abstract void setMessage(TreeMap message);

    public abstract StringString getStringString();

    public abstract void setStringString(StringString stringString);

    public void search(IRequestCycle cycle)
    {

        StringString stringString = new StringString();
        stringString.setStringOne(getCityOne());
        stringString.setStringTwo(getCityTwo());

        this.setDistanceMessages(getDbExecutor().getDistanceMessages(stringString));

    }
    public void sendSMS(IRequestCycle cycle, TreeMap message)
    {


        StringBuilder sb = new StringBuilder();
        if (message!=null)
        {

        sb.append(message.get("CITY_START")).append("-");
        sb.append(message.get("CITY_END")).append(" ");
        sb.append(message.get("CITY_DISTANCE_GEO"));
        if (message.get("NOTE_GEO")!=null)
        {
            sb.append(" ");
            sb.append(message.get("NOTE_GEO"));
        }
        }



        getDbExecutor().insertSms(getSession(), sb.toString(),SERVICE_ID);
    }
}
